﻿using System;
using System.Collections.Generic;
using System.Text;
using WeShare.WeiXin.Mp.ArticleComment.Entity;
using static WeShare.WeiXin.Common.HttpUtil;
using static WeShare.WeiXin.Common.OpenApi;
namespace WeShare.WeiXin.Mp.ArticleComment
{
    /// <summary>
    /// 图文消息留言管理。
    /// </summary>
    public class ArticleCommentApi
    {
        public BaseRes Open(string msgDataId, int index = 0, string tokenOrAppId = "")
        {
            var url = $"https://api.weixin.qq.com/cgi-bin/comment/open?access_token={GetToken(tokenOrAppId)}";
            var data = new { msg_data_id = msgDataId, index = index };
            return PostResult<BaseRes>(data, url);
        }
        public BaseRes Close(string msgDataId, int index = 0, string tokenOrAppId = "")
        {
            var url = $"https://api.weixin.qq.com/cgi-bin/comment/close?access_token={GetToken(tokenOrAppId)}";
            var data = new { msg_data_id = msgDataId, index = index };
            return PostResult<BaseRes>(data, url);
        }
        /// <summary>
        /// 查看指定文章的评论数据
        /// </summary>
        /// <param name="msgDataId">群发返回的msg_data_id</param>
        /// <param name="index">多图文时，用来指定第几篇图文，从0开始，不带默认返回该msg_data_id的第一篇图文</param>
        /// <param name="begin">起始位置</param>
        /// <param name="count">获取数目（>=50会被拒绝）</param>
        /// <param name="type">type=0 普通评论&精选评论 type=1 普通评论 type=2 精选评论</param>
        /// <param name="tokenOrAppId"></param>
        /// <returns></returns>
        //public BaseRes GetList(string msgDataId, int index = 0, int begin = 0, int count = 0, CommentType type = CommentType.All,
        //    string tokenOrAppId = "")
        //{
        //    var url = $"https://api.weixin.qq.com/cgi-bin/comment/list?access_token={GetToken(tokenOrAppId)}";
        //    var data = new
        //    {
        //        msg_data_id = msgDataId,
        //        index = index,begin=begin,
        //        count=count,type=(int)type
        //    };
        //}
    }
}
